﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;

namespace AnnRealEstate
{
    public partial class f001_main : Form
    {
        public f001_main()
        {
            InitializeComponent();

        }

        private void openToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            OpenFile();
        }

        private void OpenFile()
        {
            OpenFileDialog v_dlg = new OpenFileDialog();
            if (v_dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string path = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + v_dlg.FileName + ";Extended Properties=\"Excel 8.0;HDR=Yes;\";";
                OleDbConnection conn = new OleDbConnection(path);

                OleDbDataAdapter v_adap = new OleDbDataAdapter("Select * from [" + "Sheet1" + "$]", conn);
                DataTable dt = new DataTable();

                v_adap.Fill(dt);
                m_gridview_main.DataSource = dt;
            }
        }
        private void toolStripSplitButton1_ButtonClick(object sender, EventArgs e)
        {
            OpenFile();
        }
    }
}
